Imports SchemaCodeGen

Partial Class pages_Contents_usercontrols_UCContentsPair : Inherits UserControl

#Region "Members"
	Private m_autopostback As Boolean = True
	Private m_templateSet As CTemplateSet
	Private m_template As CTemplate
#End Region

#Region "Main Interface (Parent Entity)"
	'Friendly Urls recommended for paging within tabs
	Public Sub Display(ByVal templateSet As CTemplateSet, ByVal searchStateFromQuerystring As String, ByVal friendlyUrl As String)
		Display(templateSet, searchStateFromQuerystring)
		Me.FriendlyUrl = friendlyUrl
	End Sub
	Public Sub Display(ByVal template As CTemplate, ByVal searchStateFromQuerystring As String, ByVal friendlyUrl As String)
		Display(template, searchStateFromQuerystring)
		Me.FriendlyUrl = friendlyUrl
	End Sub

	'Simple Interface
	Public Sub Display(ByVal templateSet As CTemplateSet, ByVal searchStateFromQuerystring As String)
		m_templateSet = templateSet
		txtSearch.Text = searchStateFromQuerystring
		Dim searchStateFromForm As String = CWeb.RequestStr(txtSearch.UniqueID) 'txtSearch - postback value still not set during Page_Init
		If Title.Length = 0 Then Title = "Templates"
		ctrlRemaining.DisplayRemaining(templateSet, AutoPostback, searchStateFromForm)
		ctrlSelected.DisplaySelected(templateSet, AutoPostback)
	End Sub
	Public Sub Display(ByVal template As CTemplate, ByVal searchStateFromQuerystring As String)
		m_template = template
		txtSearch.Text = searchStateFromQuerystring
		Dim searchStateFromForm As String = CWeb.RequestStr(txtSearch.UniqueID) 'txtSearch - postback value still not set during Page_Init
		If Title.Length = 0 Then Title = "TemplateSets"
		ctrlRemaining.DisplayRemaining(template, AutoPostback, searchStateFromForm)
		ctrlSelected.DisplaySelected(template, AutoPostback)
	End Sub
#End Region

#Region "Event Handlers"
	Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click
		If Not IsNothing(m_template) Then
			Response.Redirect(CSitemap.ContentsForTemplate(m_template.TemplateId, txtSearch.Text)) 'txtSearch - postback value still not set during Page_Init
		Else
			Response.Redirect(CSitemap.ContentsForTemplateSet(m_templateSet.SetId, txtSearch.Text)) 'txtSearch - postback value still not set during Page_Init
		End If
	End Sub
#End Region

#Region "Appearance"
	Public Property Title() As String
		Get
			Return ctrlRemaining.Title
		End Get
		Set(ByVal value As String)
			ctrlRemaining.Title = value
			ctrlSelected.Title = value
		End Set
	End Property
#End Region

#Region "Behaviour"
	Public WriteOnly Property Enabled() As Boolean
		Set(ByVal value As Boolean)
			ctrlRemaining.Enabled = value
			ctrlSelected.Enabled = value
		End Set
	End Property
	Public Property AutoPostback() As Boolean
		Get
			Return m_autopostback
		End Get
		Set(ByVal value As Boolean)
			m_autopostback = value
		End Set
	End Property
#End Region

#Region "Paging"
	Public Property QueryString() As String
		Get
			Return ctrlRemaining.QueryString.Substring(0, ctrlRemaining.QueryString.Length - 1)
		End Get
		Set(ByVal value As String)
			ctrlRemaining.QueryString = value & "1"
			ctrlSelected.QueryString = value & "2"
		End Set
	End Property
	Public Property PageSize() As Integer
		Get
			Return ctrlRemaining.PageSize
		End Get
		Set(ByVal value As Integer)
			ctrlRemaining.PageSize = value
			ctrlSelected.PageSize = value
		End Set
	End Property
	Public WriteOnly Property FriendlyUrl() As String
		Set(ByVal value As String)
			ctrlRemaining.FriendlyUrl = value
			ctrlSelected.FriendlyUrl = value
		End Set
	End Property
#End Region

End Class